export default function 注册鼠标事件(root:HTMLElement){
    root.onmousedown = (e:MouseEvent) => {
        const initx = e.pageX - root.offsetLeft
        const inity = e.pageY - root.offsetTop
        const initSX = root.scrollLeft
        const initSY = root.scrollTop
        root.onmousemove =(e:MouseEvent) => {
            const newX = e.pageX- root.offsetLeft
            const newY = e.pageY- root.offsetTop
            const gapX = newX - initx
            const gapY = newY - inity
            root.scroll(initSX-gapX,initSY-gapY)
        }
        root.onmouseup = () =>{
            root.onmousemove = null
        }
        root.onmouseleave =() => {
            root.onmousemove = null
        }
        root.onmouseout=() => {
            root.onmousemove = null
        }
        
    }
    return
}
